<template>
  <div class="equipmentManage flowCloumn h100">
    <div class="constentBttom flowWrap h100 tab-switch">
      <div class="constentTree h100 treeDiv">
        <editTree
          ref="equipTree"
          :treeSetting="treeSetting"
          :hideBtn="hideBtn"
          @handleClickTree="handleClickTree"
          :haveRemark="haveRemark"
        />
      </div>
      <div class="draggingBtn">
        <widthResize></widthResize>
      </div>
      <div class="constentmain h100 tableDiv">
        <basicInfo :currentNode="currentNode" @updateTree="updateTree" menuType="edit"></basicInfo>
      </div>
    </div>
  </div>
</template>
<script>
import { locationTree } from "@/api/equipmentLedger/locationManage";
import basicInfo from "./basicInfo";
export default {
  components: { basicInfo },
  data() {
    return {
      hideBtn: true,
      haveRemark: true,
      currentNode: {},
      treeSetting: {
        data: [],
        defaultProps: {
          children: "children",
          label: "name"
        },
        clickExpand: true //是否点击节点展开
      }
    };
  },
  computed: {},
  created() {
    this.init();
  },
  mounted() {},
  methods: {
    init() {
      this.getTreeData();
    },
    updateTree(type) {
      this.getTreeData(type);
    },
    //获取设备树
    getTreeData(type) {
      locationTree().then(res => {
        this.treeSetting.data = res.data || [];
        this.$nextTick(() => {
          if (type) {
            this.$refs.equipTree.setCurrentNode(this.currentNode);
          } else {
            this.$refs.equipTree.treeNodeClick(res.data[0]);
          }
        });
      });
    },
    //点击树
    handleClickTree(node) {
      this.currentNode = node;
    }
  }
};
</script>
<style lang="less">
</style>